package main

import (
	"net/http"

	"github.com/gin-gonic/gin"
)

// 只能是get请求
func downloadFile(c *gin.Context) {
	c.Header("Content-Type", "application/octet-stream")
	c.Header("Content-Disposition", "attachment; filename=downloadFile.go")
	c.Header("Filename", "downloadFile.go")
	c.File("downloadFile.go")
}

func main() {
	router := gin.Default()
	router.StaticFS("/static", http.Dir("static"))
	router.GET("/downloadFile", downloadFile)
	router.Run(":8000")
}
